//
//  ShopTypeTableViewCell.m
//  EPBPro
//
//  Created by wucha on 2018/6/27.
//  Copyright © 2018年 fc. All rights reserved.
//

#import "ShopTypeTableViewCell.h"

@interface ShopTypeTableViewCell()
@property (nonatomic,strong) UILabel *nameLabel;
@property (nonatomic,strong) UILabel *titleLabel;
@property (nonatomic,strong) UILabel *numLabel;
@property (nonatomic,strong) UILabel *dateLabel;
@property (nonatomic,strong) UILabel *statusLabel;
@end

@implementation ShopTypeTableViewCell

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = 0;
        UIView *backView = [UIView new];
        backView.layer.cornerRadius = 10;
        backView.backgroundColor = DefaultTenantColor;
        [self.contentView addSubview:backView];
        backView.sd_layout.leftSpaceToView(self.contentView, 10).topSpaceToView(self.contentView, 5).rightSpaceToView(self.contentView, 10).bottomSpaceToView(self.contentView, 0);
        
        UILabel *nameLabel = [UILabel new];
        nameLabel.text = @"xxx";
        nameLabel.font = [UIFont systemFontOfSize:14];
        nameLabel.textColor = [UIColor whiteColor];
        [backView addSubview:nameLabel];
        nameLabel.sd_layout.leftSpaceToView(backView, 15).topSpaceToView(backView, 10).heightIs(14).rightSpaceToView(backView, 15);
        self.nameLabel = nameLabel;
        
        UILabel *titleLabel = [UILabel new];
        titleLabel.text = @"xxxxx";
        titleLabel.font = [UIFont systemFontOfSize:20];
        titleLabel.textColor = [UIColor whiteColor];
        [backView addSubview:titleLabel];
        titleLabel.sd_layout.leftSpaceToView(backView, 15).topSpaceToView(nameLabel, 15).heightIs(14).rightSpaceToView(backView, 20);
        self.titleLabel = titleLabel;
        
        UILabel *numLabel = [UILabel new];
        numLabel.text = @"xxx";
        numLabel.font = [UIFont systemFontOfSize:14];
        numLabel.textColor = [UIColor whiteColor];
        [backView addSubview:numLabel];
        numLabel.sd_layout.leftSpaceToView(backView, 15).topSpaceToView(titleLabel, 10).heightIs(14).rightSpaceToView(backView, 15);
        self.numLabel = numLabel;
        
        UILabel *dateLabel = [UILabel new];
        dateLabel.text = @"xxx";
        dateLabel.font = [UIFont systemFontOfSize:14];
        dateLabel.textColor = [UIColor whiteColor];
        [backView addSubview:dateLabel];
        dateLabel.sd_layout.leftSpaceToView(backView, 15).topSpaceToView(numLabel, 10).heightIs(14).rightSpaceToView(backView, 15);
        self.dateLabel = dateLabel;
        
        UIImageView *arrowImageView = [UIImageView new];
        arrowImageView.contentMode = UIViewContentModeCenter;
        arrowImageView.image = [UIImage imageNamed:@"machine_arrow"];
        [backView addSubview:arrowImageView];
        arrowImageView.sd_layout.rightSpaceToView(backView, 10).topSpaceToView(backView, 10).bottomSpaceToView(backView, 10).widthIs(20);
        self.arrowImageView = arrowImageView;
        
        UILabel *statusLabel = [UILabel new];
        statusLabel.text = @"xxx";
        statusLabel.textAlignment = NSTextAlignmentRight;
        statusLabel.font = [UIFont systemFontOfSize:14];
        statusLabel.textColor = [UIColor whiteColor];
        [backView addSubview:statusLabel];
        statusLabel.sd_layout.topSpaceToView(numLabel, 10).heightIs(16).rightSpaceToView(backView, 15).autoWidthRatio(0);
        [statusLabel setSingleLineAutoResizeWithMaxWidth:200];
        self.statusLabel = statusLabel;
    }
    return self;
}

-(void)setShopTypeCell:(MerchantContractInfo*)merchantContractInfo{
    self.nameLabel.text = [NSString stringWithFormat:@"合同编号:%@",merchantContractInfo.id];
    self.numLabel.text = [NSString stringWithFormat:@"数量:%@台",merchantContractInfo.equipmentNum];
    self.dateLabel.text = [NSString stringWithFormat:@"%@到%@",[Utils getTimeFront:merchantContractInfo.startDate],[Utils getTimeFront:merchantContractInfo.endDate]];
    self.titleLabel.text = merchantContractInfo.name;
    self.statusLabel.text = merchantContractInfo.status;
    
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
